#include "stdafx.h"

#include "FileHeader.h"

int FileHeader::LoadHeader(irr::io::IReadFile *pResource, irr::u32 baseOffset)
{
	if (pResource == NULL)
		return -1;
	
	irr::s16 filesNumber;
	pResource->read(&filesNumber , sizeof(irr::s16));

	if ((filesNumber <= 0) || (filesNumber >= MAX_FILES_ALLOWED))
		return -2;

	baseOffset += (2 + (filesNumber << 2));
	irr::u32 val;
	for (int i = 0; i < filesNumber; i++)
	{
		pResource->read(&val , sizeof(irr::u32));
		m_offsetsArray[i] = val + baseOffset;
	}

	m_filesNumber = filesNumber - 1;
	return 0;
}
